<?php

namespace CMS\Page\Models;
/**
 * Pomocne funkce pro entitni tridu Page.
 *
 * @author David Dusek
 */

use Doctrine\ORM\EntityRepository;

class ContentRepository extends EntityRepository {
       
    /**
     * Vrati stranku ktera je oznacena jako hemepage.
     * @return boolean 
     */
    public function getHomepage() {
        $qb = $this->_em->createQueryBuilder();
        $qb = $qb->select('c')
                 ->from("\CMS\Page\Models\Content", 'c')
                 ->where("c.homepage = 1")
                 ->setMaxResults(1);        

        try {
            $result = $qb->getQuery()->getSingleResult();
        } catch (\Doctrine\ORM\NoResultException $e) {
            $result = FALSE;
        }
        
        return $result;
    }
}
